// ActionScript file
import jpa.domain.Employee;

import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.mxml.RemoteObject;
		
		[Bindable]
		public var employee:Employee;
		[Bindable]
		public var departments:ArrayCollection;
		private var ro:RemoteObject;

		private function save():void
		{
			employee.name = employeeName.text;
			employee.idcard=idcard.text;
			employee.phone=phone.text;
			//employee.sex=radioSexGroup.selectedValue.toString();
           // employee.intime=new Date(intime.text);
            Alert.show(dp.data.toString())
			if (employee.id == 0)
			{
			
			//ro=Global.getRemoteObject("employeeController",true,create_resultHandler);
			//ro.create(employee);
			}
			else
			{
			//ro=Global.getRemoteObject("employeeController",true,update_resultHandler);
			//ro.update(employee);
			}
				
		}

		private function deleteItem():void
		{
			ro.remove(employee);		
		}

		private function create_resultHandler(event:ResultEvent):void
		{
			//carInfo.id = event.result.id;
			dispatchEvent(new EmployeeEvent(EmployeeEvent.CREATED, employee));			
		}

		private function update_resultHandler(event:ResultEvent):void
		{
			dispatchEvent(new EmployeeEvent(EmployeeEvent.UPDATED, employee));			
		}

		private function remove_resultHandler(event:ResultEvent):void
		{
			dispatchEvent(new EmployeeEvent(EmployeeEvent.DELETED, employee));			
		}
		
		private function faultHandler(event:FaultEvent):void
		{
			Alert.show(event.fault.faultDetail);
		}